<?php

use think\swoole\Table;
use app\providers\webSocket\Handler;
// use think\swoole\websocket\socketio\Handler;

return [
    'server'     => [
        'enable'     => true,
        'host'      => env('SWOOLE_HOST', '0.0.0.0'), // 监听地址
        'port'      => env('SWOOLE_PORT', 30000), // 监听端口
        'mode'      => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS
        'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP
        'options'   => [
            'pid_file'              => runtime_path() . 'log/swoole.pid',
            'log_file'              => runtime_path() . 'log/swoole.log',
            'daemonize'             => false,
            'dispatch_mode'         => 2,
            'reactor_num'           => swoole_cpu_num(),
            'worker_num'            => 50,
            'task_worker_num'       => 150,
            'enable_static_handler' => true,
            'document_root'         => root_path('public'),
            'package_max_length'    => 20 * 1024 * 1024,
            'buffer_output_size'    => 10 * 1024 * 1024,
            'socket_buffer_size'    => 128 * 1024 * 1024,
        ],
    ],
    'websocket'  => [
        'enable'        => true,
        'handler'       => Handler::class,
        'ping_interval' => 25000,
        'ping_timeout'  => 60000,
        'room'          => [
            'type'  => 'redis',
            'table' => [
                'room_rows'   => 8192,
                'room_size'   => 2048,
                'client_rows' => 4096,
                'client_size' => 2048,
            ],
            'redis' => [
                'host'     => env('redis.host', '127.0.0.1'),
                'port'     => env('redis.port', 6379),
                'password' => env('redis.password', ''),
                'max_active'    => 3,
                'max_wait_time' => 5,
            ],
        ],
        'listen'        => [
        ],
        'subscribe'     => [
        ],
    ],
    'rpc'        => [
        'server' => [
            'enable'     => false,
            'host'       => '0.0.0.0',
            'port'       => 9001,
            'worker_num' => swoole_cpu_num(),
            'services'   => [],
        ],
        'client' => [],
    ],
    //队列
    'queue'      => [
        'enable'  => false,
        'workers' => [],
    ],
    'hot_update' => [
        'enable'  => env('APP_DEBUG', false),
        'name'    => ['*.php','.env'],
        'include' => [ app_path(),'/var/www/config','/var/www/extend','/var/www/route'],
        'exclude' => ['/var/www/vendor'],
    ],
    //连接池
    'pool'       => [
        'db'    => [
            'enable'        => true,
            'max_active'    => 1040,
            'max_wait_time' => 5,
        ],
        'cache' => [
            'enable'        => true,
            'max_active'    => 150,
            'max_wait_time' => 5,
        ],
        //自定义连接池
    ],
    //高性能内存数据库    
    'tables'     => [
        'user' => [      
            'size' => 2048,       
            'columns' => [           
                ['name' => 'fd', 'type' => Table::TYPE_INT],        
                ['name' => 'type', 'type' => Table::TYPE_INT],        
                ['name' => 'uid', 'type' => Table::TYPE_INT],         
                ['name' => 'to_uid', 'type' => Table::TYPE_INT],      
                ['name' => 'tourist', 'type' => Table::TYPE_INT]      
            ]  
        ]  
    ],
    //每个worker里需要预加载以共用的实例
    'concretes'  => [
        
    ],
    //重置器
    'resetters'  => [
        
    ],
    //每次请求前需要清空的实例
    'instances'  => [

    ],
    //每次请求前需要重新执行的服务
    'services'   => [

    ],
];
